package com.kangyi.app.mapper;

import com.kangyi.app.annotation.AutoFill;
import com.kangyi.entity.GuestsStaying;
import com.kangyi.enumeration.OperationType;
import com.kangyi.vo.GuestListVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface GuestsStayingMapper {

    @Select("select * from guests_staying where user_id = #{userId} and nursing_home_id = #{nursingHomeId}")
    GuestsStaying selectByUserIdAndNursingHomeId(Integer userId, Integer nursingHomeId);

    @Select("select * from guests_staying where id = #{guestId};")
    GuestsStaying selectById(Integer guestId);

    @AutoFill(value = OperationType.UPDATE)
    void update(GuestsStaying build);

    @Select("select * from guests_staying where id_card = #{idCard};")
    GuestsStaying getGuestByIdCard(String idCard);

    @Insert("insert into guests_staying(user_id, image, name, age, gender, phone, birthday, id_card, relation, status, create_time, update_time, create_user, update_user) " +
            "VALUES(#{userId},#{image},#{name},#{age},#{gender},#{phone},#{birthday},#{idCard},#{relation},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser}) ")
    @AutoFill(value = OperationType.INSERT)
    void add(GuestsStaying build);

    @Select("select * from guests_staying where user_id = #{userId};")
    List<GuestListVO> list(Integer userId);
}
